import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:logger/logger.dart';
import 'package:mybase/base/tool/platformUtils/FFPlatform.dart';

class FFLog {
  static String start = "\u001b";
  static String end = "\u001b[0m";

  static String reset = "\x1B[0m";

  static Logger logger = Logger();

  static test(String text) {
    for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
        if (FFPlatform.isIOS) {
          stdout.write(
              'FFLog:\x1B[${i}${j}m i=$i,j=$j This is a colored error log message $reset\n');
        } else {
          debugPrint('FFLog $i.$j:${start}[$i${j}m$text${end}');
        }
      }
    }
  }

  //警告 黄色
  static warn(String text) {
    if (FFPlatform.isIOS) {
      stdout.write('FFLog:\x1B[93m${text}$reset\n');
      return;
    }
    debugPrint('FFLog:${start}[93m$text${end}');
  }

  //错误 红色
  static error(String text) {
    if (FFPlatform.isIOS) {
      stdout.write('FFLog:\x1B[91m${text}$reset\n');
      return;
    }
    debugPrint('FFLog:${start}[91m$text${end}');
  }

  //信息 紫色
  static info(String text) {
    if (FFPlatform.isIOS) {
      stdout.write('FFLog:\x1B[94m${text}$reset\n');
      return;
    }
    debugPrint('FFLog:${start}[94m$text${end}');
  }

  //成功 绿色
  static success(String text) {
    if (FFPlatform.isIOS) {
      stdout.write('FFLog:\x1B[92m${text}$reset\n');
      return;
    }
    debugPrint('FFLog:${start}[92m$text${end}');
  }
}
